# -*- coding:utf8 -*-
__author__ = 'Forcs'

from django.db import models
from wancake.models.base.models import BaseModel

class Group(BaseModel):
    """
    分组
    """
    name = models.CharField(max_length=30, null=False, default='unknown')  # 分组名称

class Rule(BaseModel):
    """
    角色
    """
    name = models.CharField(max_length=30, null=False, default='unknown')  # 角色名称
    own_product = models.CharField(max_length=512, null=False, default='')  # 所属产品id列表
    group = models.ForeignKey(Group, null=True)  # 分组

class Member(BaseModel):
    """
    成员
    """
    account = models.CharField(max_length=32, null=False, default='')  # 账号
    password = models.CharField(max_length=128, null=False, default='')  # 密码
    email = models.EmailField(null=False, default='')  # email
    group = models.ForeignKey(Group, null=True)  # 分组
    rule = models.ForeignKey(Rule, null=True)  # 角色
    first_name = models.CharField(max_length=32, null=True)  # 姓
    last_name = models.CharField(max_length=32, null=True)  # 名
    token = models.CharField(max_length=32, null=False, default='')  # 唯一标识
    session_id = models.CharField(max_length=32, null=True)  # 会话id
    date_added = models.DateTimeField(null=True)  # 加入时间
    date_last = models.DateTimeField(null=True)  # 最近一次登录时间
    is_invalid = models.BooleanField(null=False, default=False)  # 是否已经删除
    is_active = models.BooleanField(null=False, default=False)  # 是否在线

